// Copyright  2004-2008 Backplane Ltd.
//
// This file is part of Ubiquity formsPlayer
//
// Ubiquity formsPlayer is free software; you can redistribute it and/or modify it
// under the terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3 of the License, or (at your
// option) any later version.
//
// Ubiquity formsPlayer is distributed in the hope that it will be useful, but WITHOUT
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
// more details.
//
// You should have received a copy of the GNU General Public License
// along with Ubiquity formsPlayer If not, see <http://www.gnu.org/licenses/>.
//	
//
//   Purpose:  .
//   $Id$



//<summary>creates an instance of a CComObject, increments its refcount and returns its IUnknown pointer</summary>
//<remarks>the template argument must inherit from CComObjectBase</remarks>
//<param name="ppResult">pointer to location to receive the IUnknown pointer of the created object</param>
//<returns>S_OK if an object was successfully created, otherwise an error from createinstance or QueryInterface</returns>
template<typename t> HRESULT __stdcall CreateReferencedInstance(IUnknown ** ppResult)
{
	CComObject<t> * p;
	HRESULT hr = CComObject<t>::CreateInstance(&p);
	if(SUCCEEDED(hr))
		hr = p->QueryInterface(IID_IUnknown,reinterpret_cast<void**>(ppResult));
	return hr;
}
